package Controller;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by studio on 2017/2/28.
 */

@Controller
public class ImageCutController {

    @RequestMapping(value = "/imgCut2",method = RequestMethod.POST, produces="text/html;charset=utf-8")
    public String imgCut(MultipartFile file, String cut_data) {

        String type = file.getContentType();

        if(type == null || !type.toLowerCase().startsWith("image/")){
            /*文件类型不匹配*/
        }

        if(cut_data == null){
            /*没有接收到图片裁剪内容 按原图上传*/
            return "/fileUpload/handle";
        }else{
            try {
                JSONObject data = new JSONObject(cut_data);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            /*对图片文件按参数进行裁剪变换*/
        }

        /*需要传递参数提交*/
        return "/fileUpload/handle";
    }
}
